package logic

import (
	"context"
	"go.uber.org/zap"
	"homepage_srv/homepage"
	"homepage_srv/internal/dao"
	"homepage_srv/internal/svc"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartBatchDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartBatchDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartBatchDelLogic {
	return &CartBatchDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 批量减少购物车商品
func (l *CartBatchDelLogic) CartBatchDel(in *homepage.CartBatchDelRequest) (*homepage.CartBatchDelResponse, error) {
	err := dao.CartBatchDeleteGoods(int(in.UserId), in.GoodIds)
	if err != nil {
		pkg.Error("批量删除失败", zap.Error(err))
		return nil, err
	}
	return &homepage.CartBatchDelResponse{Msg: "批量删除成功"}, nil
}
